package array;

import java.util.Comparator;
import java.util.TreeSet;

/**
 * Created by fengliejv on 2022/2/27.
 */
public class MaximumDifferenceBeetweenIncreasingElements2016 {
    public int maximumDifference(int[] nums) {
        int result = -1;
        if(nums.length<2){
           return result;
        }
        int preMin = nums[0];
        for (int i = 1; i < nums.length; i++) {
            if(nums[i]!=preMin&&nums[i]-preMin>result){
                result =nums[i]-preMin;
            }
            if(nums[i]<preMin){
                preMin = nums[i];
            }
        }
        return result;
    }
}
